IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spTdoctypes_RetrieveAll')
	BEGIN
		PRINT 'Dropping Procedure spTdoctypes_RetrieveAll'
		DROP  Procedure  spTdoctypes_RetrieveAll
	END

GO

PRINT 'Creating Procedure spTdoctypes_RetrieveAll'
GO

CREATE Procedure spTdoctypes_RetrieveAll
	(
		@doctype char(50) = null, 
		@mandatory numeric = null, 
		@useqc numeric = null, 
		@initreq int = null, 
		@dispseq int = null, 
		@tooltip varchar(100) = null, 
		@barcode char(20) = null, 
		@istd numeric = null, 
		@ismb numeric = null, 
		@isrelease numeric = null, 
		@containername varchar(50) = null
	)
AS
    /* 
    ------------------------------------------------------------------------------
    - Change History
    - --------------
    - Date          Description
    ------------------------------------------------------------------------------
    - 8/22/2007	Initial version created
    ------------------------------------------------------------------------------
    */
	
	SET NOCOUNT ON
	
	-- Retrieve the relevant records
	SELECT  *
	FROM	Tdoctypes
	
	WHERE	(@doctype IS NULL OR Tdoctypes.doctype = @doctype)
	  AND	(@mandatory IS NULL OR Tdoctypes.mandatory = @mandatory)
	  AND	(@useqc IS NULL OR Tdoctypes.useqc = @useqc)
	  AND	(@initreq IS NULL OR Tdoctypes.initreq = @initreq)
	  AND	(@dispseq IS NULL OR Tdoctypes.dispseq = @dispseq)
	  AND	(@tooltip IS NULL OR Tdoctypes.tooltip LIKE @tooltip + '%')
	  AND	(@barcode IS NULL OR Tdoctypes.barcode = @barcode)
	  AND	(@istd IS NULL OR Tdoctypes.istd = @istd)
	  AND	(@ismb IS NULL OR Tdoctypes.ismb = @ismb)
	  AND	(@isrelease IS NULL OR Tdoctypes.isrelease = @isrelease)
	  AND	(@containername IS NULL OR Tdoctypes.containername LIKE @containername + '%')

	-- Return to calling method
	RETURN
GO
